from plugin.dk.Base import Base


class Image(Base):

    def __init__(self):
        pass;

    def remove(self, imageId):
        try:
            return self.docker.images.remove(imageId)
        except Exception as e:
            return e

    def getInfo(self, imageId):

        return self.docker.images.get(imageId)

    def pull(self, imageName):
        # 拉取一个image
        return self.docker.images.pull(imageName)

    def getList(self):
        # 获取所有的image 列表
        list = self.docker.images.list()
        result = []
        for image in list:
            result.append(image.attrs)
        return result

    def getSearch(self, imageName):
        # 搜索image
        try:
            return self.docker.images.search(imageName)
        except Exception as e:
            return e
